package com.iims.flowable.flow.vo.resp;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.flowable.engine.repository.ProcessDefinition;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>流程定义<p>
 *
 * @author fanpei
 * @date 2021-04-03
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("流程定义")
public class FlowProcDefDto implements Serializable {

    @ApiModelProperty("流程表单")
    private String formKey;

    @ApiModelProperty("流程定义id")
    private String processDefinitionId;

    @ApiModelProperty("流程定义Key")
    private String processDefinitionKey;

    @ApiModelProperty("流程名称")
    private String processDefinitionName;

    @ApiModelProperty("流程分类")
    private String processDefinitionCategory;

    @ApiModelProperty("版本")
    private int version;

    @ApiModelProperty("部署ID")
    private String processDefinitionDeploymentId;

    @ApiModelProperty("流程定义状态: 1:激活 , 0:挂起")
    private int suspensionState;

    @ApiModelProperty("部署时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deploymentTime;


    public void copyProcessDefinitionList(ProcessDefinition processDefinition, String formKey) {
        this.setProcessDefinitionId(processDefinition.getId());
        this.setProcessDefinitionName(processDefinition.getName());
        this.setProcessDefinitionKey(processDefinition.getKey());
        this.setProcessDefinitionCategory(processDefinition.getCategory());
        this.setVersion(processDefinition.getVersion());
        this.setProcessDefinitionDeploymentId(processDefinition.getDeploymentId());
        this.setSuspensionState(processDefinition.isSuspended() ? 0 : 1);
        this.setFormKey(formKey);
    }
}
